﻿namespace Cofoundry.Domain;

/// <summary>
/// This model is a projection of the data defined in a custom entity 
/// definition class. Much of the data is the same but the main difference
/// is that instead of using generics to identify the data model type, there
/// is instead a DataModelType property.
/// </summary>
public class CustomEntityDefinitionSummary
{
    /// <summary>
    /// Unique 6 letter code representing the entity (use uppercase)
    /// </summary>
    public string CustomEntityDefinitionCode { get; set; } = string.Empty;

    /// <summary>
    /// Plural name of the entity e.g. 'Products'
    /// </summary>
    public string NamePlural { get; set; } = string.Empty;

    /// <summary>
    /// Singlar name of the entity e.g. 'Product'
    /// </summary>
    public string Name { get; set; } = string.Empty;

    /// <summary>
    /// A short description that shows up as a tooltip for the admin 
    /// module. E.g  "Products and stock." or "News items for shareholders"
    /// </summary>
    public string Description { get; set; } = string.Empty;

    /// <summary>
    /// Indicates whether the UrlSlug property should be treated
    /// as a unique property and be validated as such. This will also affect
    /// the routing templates available for this entity because some routes require
    /// a unique slug.
    /// </summary>
    public bool ForceUrlSlugUniqueness { get; set; }

    /// <summary>
    /// Indicates whether the entities are partitioned by locale
    /// </summary>
    public bool HasLocale { get; set; }

    /// <summary>
    /// Indicates whether the url slug should be autogenerated. If this
    /// is selected then the user will not be shown the UrlSlug property. Useful
    /// if the entity will never be used in a page.
    /// </summary>
    public bool AutoGenerateUrlSlug { get; set; }

    /// <summary>
    /// Indicates whether this custom entity should always be published when saved, provided the
    /// user has permissions to do so. 
    /// </summary>
    public bool AutoPublish { get; set; }

    /// <summary>
    /// Indicates the type of ordering permitted on this custom entity type.
    /// </summary>
    public CustomEntityOrdering Ordering { get; set; }

    /// <summary>
    /// A type reference for the DataModel class used to persist custom data.
    /// </summary>
    public required Type DataModelType { get; set; }

    /// <summary>
    /// Terminology to use when displaying the custom entity, e.g. Title, Url Slug
    /// </summary>
    public IReadOnlyDictionary<string, string> Terms { get; set; } = ImmutableDictionary<string, string>.Empty;
}
